<?php
namespace Admin\Controller;
use Think\Controller;
use Think\Image;
class EfficiencyController extends PublicController {


	function _initialize() {
		parent::_initialize ();
	}
	//商务列表
    public function index(){
        $search = I('search');
        if($search){
            $where['user_name'] = array('like',"%$search%");
            $this->assign("search", $search);
        }

        if(I('p')){
            $p = I('p');
        }else{
             $p = 1;
        }
        $header = C('header')['efficiency'];
        // $where['status'] = 0;
        // $count =    M('query')
        //             ->alias("q")
        //             ->join("left join pt_site as s on s.query_id=q.id")
        //             ->join("left join pt_user as u on u.user_id=q.user_id")
        //             ->field('s.site,u.user_name as userName,q.kwd,q.logtime')
        //             ->where($where)
        //             ->count();



        $count = 0;
        // $list = 0;

        $list = array(
            array(
                '1','盛云聪','www.bonnidee.cn','盛云聪PHP','百度PC','2019-02-11 08:23:56','10','20','14','280','进行中','<a href="#" class="details">查看详情</a>'
            ),
            array(
                '1','盛云聪','www.bonnidee.cn','盛云聪PHP','百度PC','2019-02-11 08:23:56','10','20','14','280','进行中','<a href="#" class="details">查看详情</a>'
            ),
            array(
                '1','盛云聪','www.bonnidee.cn','盛云聪PHP','百度PC','2019-02-11 08:23:56','10','20','14','280','进行中','<a href="#" class="details">查看详情</a>'
            ),
            array(
                '1','盛云聪','www.bonnidee.cn','盛云聪PHP','百度PC','2019-02-11 08:23:56','10','20','14','280','进行中','<a href="#" class="details">查看详情</a>'
            ),
            array(
                '1','盛云聪','www.bonnidee.cn','盛云聪PHP','百度PC','2019-02-11 08:23:56','10','20','14','280','进行中','<a href="#" class="details">查看详情</a>'
            ),
        );

        $Page = new \Think\Page($count, 30);
        $Page->setConfig('theme', "%UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%");
        $show = $Page->show(); // 分页显示输出





        // $list = M('query')
        //         ->alias("q")
        //         ->join("left join pt_site as s on s.query_id=q.id")
        //         ->field('q.id,a.user_name as adminName,u.user_name as userName,q.kwd,q.logtime')
        //         ->order('q.id desc')
        //         ->limit($Page->firstRow . ',' . $Page->listRows)
        //         ->select();
        // foreach ($list as $k => $v) {
        //     $list[$k]['logtime'] = date('Y-m-d H:i:s',$v['logtime']);
        //     $list[$k]['order'] = "<a href='#' class='details' query_id='{$v['id']}'>订单详情</a>";
        //     $list[$k]['status'] = "未审核";
        // }

        // var_dump($show);exit;
        $show = str_replace('<div>','',$show);
        $show = str_replace('current','active',$show);
        $show = str_replace('<<<','上一页<',$show);
        $show = str_replace('>>>','>下一页',$show);
        $show = str_replace('</div>','',$show);
        // echo  htmlentities($show,ENT_QUOTES,"UTF-8");exit;
        // $show = preg_replace('//s*/', '', $show);
        if($count <= 10){
            $show = '<a href="" class="active">1</a>';
        }
        $this->assign("page", $show); // 赋值分页输出
        $this->assign("count", $count);
        $this->assign("p", $p);
        $this->assign("header", $header);
        $this->assign("list", $list);
        layout('Layout/twolayout');
        $this->display();
    }



    public function efficiencyday(){
        $search = I('search');
        if($search){
            $where['user_name'] = array('like',"%$search%");
            $this->assign("search", $search);
        }

        if(I('p')){
            $p = I('p');
        }else{
             $p = 1;
        }
        $header = C('header')['wordDay'];
        // $where['status'] = 0;
        // $count =    M('query')
        //             ->alias("q")
        //             ->join("left join pt_site as s on s.query_id=q.id")
        //             ->join("left join pt_user as u on u.user_id=q.user_id")
        //             ->field('s.site,u.user_name as userName,q.kwd,q.logtime')
        //             ->where($where)
        //             ->count();



        $count = 0;
        // $list = 0;

        $list = array(
            array(
                '1','盛云聪','www.bonnidee.cn','盛云聪PHP','百度PC','2019-02-11 08:23:56','58','8','10','20','14','280','进行中'
            ),
            array(
                '1','盛云聪','www.bonnidee.cn','盛云聪PHP','百度PC','2019-02-11 08:23:56','58','8','10','20','14','280','进行中'
            ),
            array(
                '1','盛云聪','www.bonnidee.cn','盛云聪PHP','百度PC','2019-02-11 08:23:56','58','8','10','20','14','280','进行中'
            ),
            array(
                '1','盛云聪','www.bonnidee.cn','盛云聪PHP','百度PC','2019-02-11 08:23:56','58','8','10','20','14','280','进行中'
            ),
            array(
                '1','盛云聪','www.bonnidee.cn','盛云聪PHP','百度PC','2019-02-11 08:23:56','58','8','10','20','14','280','进行中'
            ),
        );

        $Page = new \Think\Page($count, 30);
        $Page->setConfig('theme', "%UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%");
        $show = $Page->show(); // 分页显示输出





        // $list = M('query')
        //         ->alias("q")
        //         ->join("left join pt_site as s on s.query_id=q.id")
        //         ->field('q.id,a.user_name as adminName,u.user_name as userName,q.kwd,q.logtime')
        //         ->order('q.id desc')
        //         ->limit($Page->firstRow . ',' . $Page->listRows)
        //         ->select();
        // foreach ($list as $k => $v) {
        //     $list[$k]['logtime'] = date('Y-m-d H:i:s',$v['logtime']);
        //     $list[$k]['order'] = "<a href='#' class='details' query_id='{$v['id']}'>订单详情</a>";
        //     $list[$k]['status'] = "未审核";
        // }

        // var_dump($show);exit;
        $show = str_replace('<div>','',$show);
        $show = str_replace('current','active',$show);
        $show = str_replace('<<<','上一页<',$show);
        $show = str_replace('>>>','>下一页',$show);
        $show = str_replace('</div>','',$show);
        // echo  htmlentities($show,ENT_QUOTES,"UTF-8");exit;
        // $show = preg_replace('//s*/', '', $show);
        if($count <= 10){
            $show = '<a href="" class="active">1</a>';
        }
        $this->assign("page", $show); // 赋值分页输出
        $this->assign("count", $count);
        $this->assign("p", $p);
        $this->assign("header", $header);
        $this->assign("list", $list);
        layout('Layout/twolayout');
        $this->display();
    }


    public function efficiencystatistical(){
        $search = I('search');
        if($search){
            $where['user_name'] = array('like',"%$search%");
            $this->assign("search", $search);
        }

        if(I('p')){
            $p = I('p');
        }else{
             $p = 1;
        }
        // $header = C('header')['wordDay'];
        $header = [];
        // $where['status'] = 0;
        // $count =    M('query')
        //             ->alias("q")
        //             ->join("left join pt_site as s on s.query_id=q.id")
        //             ->join("left join pt_user as u on u.user_id=q.user_id")
        //             ->field('s.site,u.user_name as userName,q.kwd,q.logtime')
        //             ->where($where)
        //             ->count();



        $count = 0;
        // $list = 0;

        $list = array(
            array(
                '<a href="/Admin/efficiency/efficiencystatisticalu">盛云聪</a>','100','43','43%','100','43','43%','100','43','43%','100','43','43%','100','43','43%','100','43','43%','600','258','43%'
            ),
            array(
                '<a href="/Admin/efficiency/efficiencystatisticalu">盛云聪</a>','100','43','43%','100','43','43%','100','43','43%','100','43','43%','100','43','43%','100','43','43%','600','258','43%'
            ),
            array(
                '<a href="/Admin/efficiency/efficiencystatisticalu">盛云聪</a>','100','43','43%','100','43','43%','100','43','43%','100','43','43%','100','43','43%','100','43','43%','600','258','43%'
            ),
            array(
                '<a href="/Admin/efficiency/efficiencystatisticalu">盛云聪</a>','100','43','43%','100','43','43%','100','43','43%','100','43','43%','100','43','43%','100','43','43%','600','258','43%'
            ),
            array(
                '<a href="/Admin/efficiency/efficiencystatisticalu">盛云聪</a>','100','43','43%','100','43','43%','100','43','43%','100','43','43%','100','43','43%','100','43','43%','600','258','43%'
            ),
        );

        $Page = new \Think\Page($count, 30);
        $Page->setConfig('theme', "%UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%");
        $show = $Page->show(); // 分页显示输出





        // $list = M('query')
        //         ->alias("q")
        //         ->join("left join pt_site as s on s.query_id=q.id")
        //         ->field('q.id,a.user_name as adminName,u.user_name as userName,q.kwd,q.logtime')
        //         ->order('q.id desc')
        //         ->limit($Page->firstRow . ',' . $Page->listRows)
        //         ->select();
        // foreach ($list as $k => $v) {
        //     $list[$k]['logtime'] = date('Y-m-d H:i:s',$v['logtime']);
        //     $list[$k]['order'] = "<a href='#' class='details' query_id='{$v['id']}'>订单详情</a>";
        //     $list[$k]['status'] = "未审核";
        // }

        // var_dump($show);exit;
        $show = str_replace('<div>','',$show);
        $show = str_replace('current','active',$show);
        $show = str_replace('<<<','上一页<',$show);
        $show = str_replace('>>>','>下一页',$show);
        $show = str_replace('</div>','',$show);
        // echo  htmlentities($show,ENT_QUOTES,"UTF-8");exit;
        // $show = preg_replace('//s*/', '', $show);
        if($count <= 10){
            $show = '<a href="" class="active">1</a>';
        }
        $this->assign("page", $show); // 赋值分页输出
        $this->assign("count", $count);
        $this->assign("p", $p);
        $this->assign("header", $header);
        $this->assign("list", $list);
        layout('Layout/twolayout');
        $this->display();
    }


    public function efficiencystatisticalu(){
        $search = I('search');
        if($search){
            $where['user_name'] = array('like',"%$search%");
            $this->assign("search", $search);
        }

        if(I('p')){
            $p = I('p');
        }else{
             $p = 1;
        }
        // $header = C('header')['wordDay'];
        $header = [];
        // $where['status'] = 0;
        // $count =    M('query')
        //             ->alias("q")
        //             ->join("left join pt_site as s on s.query_id=q.id")
        //             ->join("left join pt_user as u on u.user_id=q.user_id")
        //             ->field('s.site,u.user_name as userName,q.kwd,q.logtime')
        //             ->where($where)
        //             ->count();



        $count = 0;
        // $list = 0;

        $list = array(
            array(
                '聪聪','100','43','43%','100','43','43%','100','43','43%','100','43','43%','100','43','43%','100','43','43%','600','258','43%'
            ),
            array(
                '聪聪','100','43','43%','100','43','43%','100','43','43%','100','43','43%','100','43','43%','100','43','43%','600','258','43%'
            ),
            array(
                '聪聪','100','43','43%','100','43','43%','100','43','43%','100','43','43%','100','43','43%','100','43','43%','600','258','43%'
            ),
            array(
                '聪聪','100','43','43%','100','43','43%','100','43','43%','100','43','43%','100','43','43%','100','43','43%','600','258','43%'
            ),
            array(
                '聪聪','100','43','43%','100','43','43%','100','43','43%','100','43','43%','100','43','43%','100','43','43%','600','258','43%'
            ),
        );

        $Page = new \Think\Page($count, 30);
        $Page->setConfig('theme', "%UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%");
        $show = $Page->show(); // 分页显示输出





        // $list = M('query')
        //         ->alias("q")
        //         ->join("left join pt_site as s on s.query_id=q.id")
        //         ->field('q.id,a.user_name as adminName,u.user_name as userName,q.kwd,q.logtime')
        //         ->order('q.id desc')
        //         ->limit($Page->firstRow . ',' . $Page->listRows)
        //         ->select();
        // foreach ($list as $k => $v) {
        //     $list[$k]['logtime'] = date('Y-m-d H:i:s',$v['logtime']);
        //     $list[$k]['order'] = "<a href='#' class='details' query_id='{$v['id']}'>订单详情</a>";
        //     $list[$k]['status'] = "未审核";
        // }

        // var_dump($show);exit;
        $show = str_replace('<div>','',$show);
        $show = str_replace('current','active',$show);
        $show = str_replace('<<<','上一页<',$show);
        $show = str_replace('>>>','>下一页',$show);
        $show = str_replace('</div>','',$show);
        // echo  htmlentities($show,ENT_QUOTES,"UTF-8");exit;
        // $show = preg_replace('//s*/', '', $show);
        if($count <= 10){
            $show = '<a href="" class="active">1</a>';
        }
        $this->assign("page", $show); // 赋值分页输出
        $this->assign("count", $count);
        $this->assign("p", $p);
        $this->assign("header", $header);
        $this->assign("list", $list);
        layout('Layout/twolayout');
        $this->display();
    }




     public function edit(){
        $id = I('id');
        if(!$id){
            $this->ajaxreturn(array('state' => 0, 'data' => '信息错误'), 'json');
        }
        $where['id'] = $id;
        
        $list = M('business')->where($where)->field('id,admin_id,user_name,phone,email,qq')->find();
        if(empty($list)){
            $this->ajaxreturn(array('state' => 0, 'data' => '不存在该用户'), 'json');
        }else{
            $value = $list['admin_id'];
            unset($list['admin_id']);
            $this->ajaxreturn(array('state' => 1, 'data' => $list,'value'=>$value), 'json');
        }
    }


    //商务编辑
    public function handle(){
        $res = I('');
        if($res['act'] == 'add'){
           
            if(!$res['user_name'] ||  !$res['phone'] || !$res['qq'] || !$res['email'] || !$res['admin_id']){
                $this->error('请填写完整信息');
            }
           
            $res['add_time'] = time();
            $res['update_time'] = time();
            $res['type'] = 1;
            $list = M('business')->add($res);
            if($list){
                $this->success("添加成功", U("Business/index"));exit;
            }else{
                $this->error("添加失败");exit;
            }

            $this->display();
        }elseif($res['act'] == 'edit'){
            $data = [];
            $update['user_name'] = $res['user_name'];
            $update['phone'] = $res['phone'];
            $update['email'] = $res['email'];
            $update['admin_id'] = $res['admin_id'];
            $update['qq'] = $res['qq'];
            $update['update_time'] = time();
            $where['id'] = $res['id'];
            $list = M('business')->where($where)->save($update);
            if($list){
                $this->success("更新成功", U("Business/index"));exit;
            }else{
                $this->error("更新失败");exit;
            }
        }elseif($res['act'] == 'del'){
            $where['id'] = $res['id'];
            $list = M('business')->where($where)->delete($res);
            if($list){
                $this->success("删除成功", U("Business/index"));exit;
            }else{
                $this->error("删除失败");exit;
            }
        }
       
        
    }




     public function details(){
        $list = array(
            array(
                '1','盛云聪','盛云聪PHP','2019-02-11 08:23:56','排名消费','45','任务达标扣费'
            ),
            array(
                '1','盛云聪','盛云聪PHP','2019-02-11 08:23:56','排名消费','45','任务达标扣费'
            ),
            array(
                '1','盛云聪','盛云聪PHP','2019-02-11 08:23:56','排名消费','45','任务达标扣费'
            ),
            array(
                '1','盛云聪','盛云聪PHP','2019-02-11 08:23:56','排名消费','45','任务达标扣费'
            ),
            array(
                '1','盛云聪','盛云聪PHP','2019-02-11 08:23:56','排名消费','45','任务达标扣费'
            ),
            array(
                '1','盛云聪','盛云聪PHP','2019-02-11 08:23:56','排名消费','45','任务达标扣费'
            ),
            array(
                '1','盛云聪','盛云聪PHP','2019-02-11 08:23:56','排名消费','45','任务达标扣费'
            ),
        );
        $this->ajaxreturn(array('state' => 1, 'data' => $list), 'json');
    }

}